# 手动下载 Electron 脚本
$electronVersion = "35.7.0"
$cacheDir = "$env:USERPROFILE\.electron"
$zipFile = "electron-v$electronVersion-win32-x64.zip"

# 创建缓存目录
New-Item -ItemType Directory -Force -Path $cacheDir

# 使用 npmmirror 镜像下载
$url = "https://registry.npmmirror.com/-/binary/electron/$electronVersion/$zipFile"
$output = "$cacheDir\$zipFile"

Write-Host "正在从镜像源下载 Electron v$electronVersion..."
try {
    Invoke-WebRequest -Uri $url -OutFile $output -UseBasicParsing
    Write-Host "下载完成: $output"
} catch {
    Write-Host "下载失败: $($_.Exception.Message)"
    
    # 尝试备用镜像
    $backupUrl = "https://mirrors.huaweicloud.com/electron/$electronVersion/$zipFile"
    Write-Host "尝试华为云镜像源..."
    try {
        Invoke-WebRequest -Uri $backupUrl -OutFile $output -UseBasicParsing
        Write-Host "华为云镜像下载完成: $output"
    } catch {
        Write-Host "华为云镜像也失败: $($_.Exception.Message)"
    }
} 